import React from "react";
import PureRenderMixin from 'react-addons-pure-render-mixin'
import ButtonTab from '../BottomBar/index.jsx';
import Home from '../Home/index.jsx';
import { Switch, Route } from 'react-router-dom'
import Loading from './Loading.jsx';
import Loadable from 'react-loadable';
import {connect} from 'react-redux';
import { bindActionCreators } from 'redux';
import { changeTab } from '../actions/tabAction'
const Me = Loadable({
    loader: () => import(/* webpackChunkName: "me" */'../Me/Me.jsx'),
    loading: Loading,
});

const Order = Loadable({
    loader: () => import(/* webpackChunkName: "order" */'../Order/order.jsx'),
    loading: Loading,
});
import "./index.scss";
class Main extends React.Component {
  constructor(props) {
    super(props)
    this.state = {}
    this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
  }
  componentDidMount() {
      this.props.changeTabAction({
          activeKey: 'home'
      })
  }

  shouldComponentUpdate() {}

  render() {
    return (
      <div className='box'>
          <Switch>
              <Route exact path="/" component={Home} />
              <Route exact path="/home" component={Home} />
              <Route path="/order" component={Order} />
              <Route path="/my" component={Me} />
          </Switch>
        <ButtonTab></ButtonTab>
      </div>
    );
  }
}

export default connect(
    () => ({

    }),
    (dispatch) => ({
        changeTabAction: bindActionCreators(changeTab, dispatch)
    })
)(Main)
